package com.my.shetuan.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.my.shetuan.entity.Student;
import com.my.shetuan.mapper.StudentMapper;
import com.my.shetuan.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class PageConteroller {

    @Autowired
    private StudentService studentService;

  
    @GetMapping("/dynamic_table")
    public String dynamicTable(@RequestParam(value = "pn",defaultValue = "1") int pn,
                               @RequestParam(value = "limit",defaultValue = "10")int limit,
                               Model model){
        List<Student> list = studentService.list(null);
        Page<Student> page = new Page<>(pn, limit);
        long total = page.getTotal();//总数
        long pages = page.getPages();//总页数
        long current = page.getCurrent();//当前页数
        List<Student> records = page.getRecords();//总的消息
        IPage<Student> page1 = studentService.page(page, null);
        model.addAttribute("page1",page1);
        model.addAttribute("limit",limit);
        return "table/dynamic_table";
    }



    @GetMapping("/form_validation")
    public String formValidation(){
        return "form/form_validation";
    }
}
